from flask import Flask
from flask import request
from models.load_model import Model

# load model only once !
cls = Model()

# An instance of this class will be our WSGI application
app = Flask(__name__)

# tell Flask what URL should trigger our function
@app.route('/api/classifier', methods=['POST'])
def predict_api():
    input_json = request.get_json(force=False, silent=False, cache=True)
    response = cls.predict(input_json['input_str'])
    return response


if __name__ == '__main__':
    app.run()